package javacafe.serviceimple;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javacafe.dao.PagingDAO;
import javacafe.dao.StudyDAO;
import javacafe.daoimpl.PagingDAOImple;
import javacafe.daoimpl.StudyDAOImpl;
import javacafe.dto.studybbs.StudyBBSDTO;
import javacafe.dto.studybbs.StudyBBSReplyDTO;
import javacafe.dto.studybbs.StudyPostDTO;
import javacafe.service.StudyBBSService;
import javacafe.service.StudyService;

public class StudyBBSServiceImpl implements StudyBBSService {

	private static StudyBBSService service = null;
	private static StudyBBSDAO dao = null;
	
	public static StudyBBSService getInstance(){
		if (service == null) {
			service = new StudyBBSServiceImpl();
		}
		return service;
	}
	
	public StudyBBSServiceImpl() {
		dao = StudyBBSDAOImpl.getInstance();
	}
	
	@Override
	public List<StudyBBSDTO> getStudyBBSList(int study_no) {
		return dao.getStudyBBSList(study_no);
	}

	@Override
	public void createBBS(StudyBBSDTO dto) {
		dao.createBBS(dto);
	}

	@Override
	public void updateBBS(StudyBBSDTO dto) {
		dao.updateBBS(dto);
	}

	@Override
	public List<StudyPostDTO> getStudyPostlist(int sbbsNo) {
		List<StudyPostDTO> list = null;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("sbbs_no", sbbsNo);
		return dao.getStudyPostList(map);
	}

	@Override
	public void insertPost(StudyPostDTO dto) {
		dao.insertPost(dto);
	}

	@Override
	public StudyPostDTO getStudyPost(int spNo) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("sp_no", spNo);
		return dao.getStudyPost(map);
	}

	@Override
	public void insertReply(StudyBBSReplyDTO replyDTO) {
		dao.insertReply(replyDTO);
	}

	@Override
	public List<StudyBBSReplyDTO> getReplyList(int spNo) {
		return dao.getReplyList(spNo);
	}

	@Override
	public void updateReply(StudyBBSReplyDTO replyDTO) {
		dao.updateReply(replyDTO);
	}

	@Override
	public void deleteReply(StudyBBSReplyDTO replyDTO) {
		dao.deleteReply(replyDTO);
	}

	@Override
	public void deletePost(StudyPostDTO postDto) {
		dao.deletePost(postDto);
	}

	@Override
	public StudyBBSDTO getStudyBBS(int sbbsNo) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("sbbs_no", sbbsNo);
		return dao.getStudyBBS(map);
	}

	@Override
	public void updatePost(StudyPostDTO postDto) {
		dao.updatePost(postDto);
	}

}
